<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Quasinumeric Relations</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Quasinumeric Relations' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">assertions</a></li><li><a href="index.html#8">Chapter 8: Predicates</a></li><li><b>Quasinumeric Relations</b></li></ul></div>
<p class="purpose">To define the binary predicates corresponding to numerical comparisons.</p>

<ul class="toc"><li><a href="8-qr.html#SP2">&#167;2. Family</a></li><li><a href="8-qr.html#SP3">&#167;3. Initial stock</a></li><li><a href="8-qr.html#SP4">&#167;4. Typechecking</a></li><li><a href="8-qr.html#SP5">&#167;5. Assertion</a></li><li><a href="8-qr.html#SP6">&#167;6. Compilation</a></li><li><a href="8-qr.html#SP7">&#167;7. Problem message text</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>The inequality relations \(&lt;\), \(&gt;\), \(\leq\), and \(\geq\), which can be
applied not only to numbers but also to units (height, length and so on).
</p>

<p class="commentary">It might seem redundant to define both <span class="extract"><span class="extract-syntax">R_numerically_greater_than</span></span> (which makes the
numerical test \(a&gt;b\)) and also <span class="extract"><span class="extract-syntax">R_numerically_less_than</span></span> (which tests \(a&lt;b\)). Why
not define only one, and get the other meaning free as its reversal? The
answer is that is more convenient not to, because it allows us to give both
of them names.
</p>

<p class="commentary">There is no numerical equality relation \(=\) as such: numbers use the same
equality BP as everything else.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R_numerically_greater_than</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R_numerically_less_than</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Family.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::start</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::start</span></span>:<br/>Assertions Module - <a href="1-am.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax"> = </span><span class="identifier-syntax">BinaryPredicateFamilies::new</span><span class="plain-syntax">();</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">, </span><span class="identifier-syntax">STOCK_BPF_MTID</span><span class="plain-syntax">, </span><a href="8-qr.html#SP3" class="function-link"><span class="function-syntax">Calculus::QuasinumericRelations::stock</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">, </span><span class="identifier-syntax">TYPECHECK_BPF_MTID</span><span class="plain-syntax">, </span><a href="8-qr.html#SP4" class="function-link"><span class="function-syntax">Calculus::QuasinumericRelations::typecheck</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">, </span><span class="identifier-syntax">ASSERT_BPF_MTID</span><span class="plain-syntax">, </span><a href="8-qr.html#SP5" class="function-link"><span class="function-syntax">Calculus::QuasinumericRelations::assert</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">, </span><span class="identifier-syntax">SCHEMA_BPF_MTID</span><span class="plain-syntax">, </span><a href="8-qr.html#SP6" class="function-link"><span class="function-syntax">Calculus::QuasinumericRelations::schema</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">, </span><span class="identifier-syntax">DESCRIBE_FOR_PROBLEMS_BPF_MTID</span><span class="plain-syntax">, </span><a href="8-qr.html#SP7" class="function-link"><span class="function-syntax">Calculus::QuasinumericRelations::describe_for_problems</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">METHOD_ADD</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">, </span><span class="identifier-syntax">DESCRIBE_FOR_INDEX_BPF_MTID</span><span class="plain-syntax">, </span><a href="8-qr.html#SP7" class="function-link"><span class="function-syntax">Calculus::QuasinumericRelations::describe_for_index</span></a><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Initial stock.</b>These relations are all hard-wired in.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::stock</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::stock</span></span>:<br/><a href="8-qr.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">self</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">n</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">n</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">bp_term_details</span><span class="plain-syntax"> </span><span class="identifier-syntax">number_term</span><span class="plain-syntax"> = </span><span class="identifier-syntax">BPTerms::new</span><span class="plain-syntax">(</span><span class="identifier-syntax">KindSubjects::from_kind</span><span class="plain-syntax">(</span><span class="identifier-syntax">K_number</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">R_numerically_greater_than</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">BinaryPredicates::make_pair</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">, </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"greater-than"</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">Calculus::Schemas::new</span><span class="plain-syntax">(</span><span class="string-syntax">"*1 &gt; *2"</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PreformUtilities::wording</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;relation-names&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">GT_RELATION_NAME</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">R_numerically_less_than</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">BinaryPredicates::make_pair</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">, </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"less-than"</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">Calculus::Schemas::new</span><span class="plain-syntax">(</span><span class="string-syntax">"*1 &lt; *2"</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PreformUtilities::wording</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;relation-names&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">LT_RELATION_NAME</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">BinaryPredicates::make_pair</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">, </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"at-least"</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">Calculus::Schemas::new</span><span class="plain-syntax">(</span><span class="string-syntax">"*1 &gt;= *2"</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PreformUtilities::wording</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;relation-names&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">GE_RELATION_NAME</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">BinaryPredicates::make_pair</span><span class="plain-syntax">(</span><span class="identifier-syntax">quasinumeric_bp_family</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">, </span><span class="identifier-syntax">number_term</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">I</span><span class="string-syntax">"at-most"</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">Calculus::Schemas::new</span><span class="plain-syntax">(</span><span class="string-syntax">"*1 &lt;= *2"</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">PreformUtilities::wording</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;relation-names&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">LE_RELATION_NAME</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">BinaryPredicates::set_index_details</span><span class="plain-syntax">(</span><span class="identifier-syntax">R_numerically_greater_than</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">, </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">BinaryPredicates::set_index_details</span><span class="plain-syntax">(</span><span class="identifier-syntax">R_numerically_less_than</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">, </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">BinaryPredicates::set_index_details</span><span class="plain-syntax">(</span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">, </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">BinaryPredicates::set_index_details</span><span class="plain-syntax">(</span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">, </span><span class="string-syntax">"arithmetic value"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Typechecking.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::typecheck</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::typecheck</span></span>:<br/><a href="8-qr.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">self</span><span class="plain-syntax">, </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> **</span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> **</span><span class="identifier-syntax">kinds_required</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc_problem_kit</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tck</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Kinds::compatible</span><span class="plain-syntax">(</span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[1]) == </span><span class="identifier-syntax">NEVER_MATCH</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Kinds::compatible</span><span class="plain-syntax">(</span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[1], </span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[0]) == </span><span class="identifier-syntax">NEVER_MATCH</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tck</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">log_to_I6_text</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Unable to apply inequality of %u and %u\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(5, </span><span class="identifier-syntax">kinds_of_terms</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::tcp_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_InequalityFailed</span><span class="plain-syntax">), </span><span class="identifier-syntax">tck</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"that would mean comparing two kinds of value which cannot mix - "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"%4 and %5 - so this must be incorrect."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NEVER_MATCH</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ALWAYS_MATCH</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Assertion.</b>These relations cannot be asserted.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::assert</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::assert</span></span>:<br/><a href="8-qr.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">self</span><span class="plain-syntax">, </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">infs0</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec0</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">inference_subject</span><span class="plain-syntax"> *</span><span class="identifier-syntax">infs1</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">spec1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Compilation.</b>For integer arithmetic, we need do nothing special: these relations can be
compiled from their schemas. But real numbers have to be handled by a function
call in I6.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::schema</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::schema</span></span>:<br/><a href="8-qr.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">self</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">, </span><span class="identifier-syntax">annotated_i6_schema</span><span class="plain-syntax"> *</span><span class="identifier-syntax">asch</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">st</span><span class="plain-syntax">[2];</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">st</span><span class="plain-syntax">[0] = </span><span class="identifier-syntax">Cinders::kind_of_term</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">pt0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">st</span><span class="plain-syntax">[1] = </span><span class="identifier-syntax">Cinders::kind_of_term</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">pt1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">TEST_ATOM_TASK:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">st</span><span class="plain-syntax">[0]) &amp;&amp; (</span><span class="identifier-syntax">st</span><span class="plain-syntax">[1])) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">text_stream</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">promote_left</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">, </span><span class="identifier-syntax">promote_right</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Kinds::FloatingPoint::uses_floating_point</span><span class="plain-syntax">(</span><span class="identifier-syntax">st</span><span class="plain-syntax">[0])) ||</span>
<span class="plain-syntax">                    (</span><span class="identifier-syntax">Kinds::FloatingPoint::uses_floating_point</span><span class="plain-syntax">(</span><span class="identifier-syntax">st</span><span class="plain-syntax">[1]))) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::FloatingPoint::uses_floating_point</span><span class="plain-syntax">(</span><span class="identifier-syntax">st</span><span class="plain-syntax">[0]) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">promote_left</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::FloatingPoint::uses_floating_point</span><span class="plain-syntax">(</span><span class="identifier-syntax">st</span><span class="plain-syntax">[1]) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">promote_right</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">cr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Kinds::Behaviour::get_comparison_routine</span><span class="plain-syntax">(</span><span class="identifier-syntax">K_real_number</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">cr</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Kinds::Behaviour::get_comparison_routine</span><span class="plain-syntax">(</span><span class="identifier-syntax">st</span><span class="plain-syntax">[0]);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Str::len</span><span class="plain-syntax">(</span><span class="identifier-syntax">cr</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) || (</span><span class="identifier-syntax">Str::eq_wide_string</span><span class="plain-syntax">(</span><span class="identifier-syntax">cr</span><span class="plain-syntax">, </span><span class="identifier-syntax">U</span><span class="string-syntax">"signed"</span><span class="plain-syntax">))) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>

<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">promote_left</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_greater_than</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_2(NUMBER_TY_to_REAL_NUMBER_TY(*1), *2) &gt; 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_less_than</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_2(NUMBER_TY_to_REAL_NUMBER_TY(*1), *2) &lt; 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_2(NUMBER_TY_to_REAL_NUMBER_TY(*1), *2) &gt;= 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_2(NUMBER_TY_to_REAL_NUMBER_TY(*1), *2) &lt;= 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">promote_right</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_greater_than</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, NUMBER_TY_to_REAL_NUMBER_TY(*2)) &gt; 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_less_than</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, NUMBER_TY_to_REAL_NUMBER_TY(*2)) &lt; 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, NUMBER_TY_to_REAL_NUMBER_TY(*2)) &gt;= 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, NUMBER_TY_to_REAL_NUMBER_TY(*2)) &lt;= 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_greater_than</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, *2) &gt; 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_less_than</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, *2) &lt; 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_greater_than_or_equal_to</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, *2) &gt;= 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">bp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">R_numerically_less_than_or_equal_to</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Calculus::Schemas::modify</span><span class="plain-syntax">(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">schema</span><span class="plain-syntax">, </span><span class="string-syntax">"*_1(*1, *2) &lt;= 0"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">problem_count</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"$0 and $0; %u and %u\n"</span><span class="plain-syntax">, &amp;(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">pt0</span><span class="plain-syntax">), &amp;(</span><span class="identifier-syntax">asch</span><span class="plain-syntax">-&gt;</span><span class="identifier-syntax">pt1</span><span class="plain-syntax">), </span><span class="identifier-syntax">st</span><span class="plain-syntax">[0], </span><span class="identifier-syntax">st</span><span class="plain-syntax">[1]);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="string-syntax">"null kind in equality test"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Problem message text.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::describe_for_problems</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::describe_for_problems</span></span>:<br/><a href="8-qr.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">self</span><span class="plain-syntax">, </span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Calculus::QuasinumericRelations::describe_for_index</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Calculus::QuasinumericRelations::describe_for_index</span></span>:<br/><a href="8-qr.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">bp_family</span><span class="plain-syntax"> *</span><span class="identifier-syntax">self</span><span class="plain-syntax">, </span><span class="identifier-syntax">OUTPUT_STREAM</span><span class="plain-syntax">, </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">bp</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WRITE</span><span class="plain-syntax">(</span><span class="string-syntax">"numeric"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="8-terr.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-am.html">1</a></li><li class="progresschapter"><a href="2-bv.html">2</a></li><li class="progresschapter"><a href="3-dlr.html">3</a></li><li class="progresschapter"><a href="4-nr.html">4</a></li><li class="progresschapter"><a href="5-id.html">5</a></li><li class="progresschapter"><a href="6-rls.html">6</a></li><li class="progresschapter"><a href="7-tc.html">7</a></li><li class="progresscurrentchapter">8</li><li class="progresssection"><a href="8-kpr.html">kpr</a></li><li class="progresssection"><a href="8-tap.html">tap</a></li><li class="progresssection"><a href="8-tcp.html">tcp</a></li><li class="progresssection"><a href="8-terr.html">terr</a></li><li class="progresscurrent">qr</li><li class="progresssection"><a href="8-tur.html">tur</a></li><li class="progresssection"><a href="8-er.html">er</a></li><li class="progresssection"><a href="8-lr.html">lr</a></li><li class="progresssection"><a href="8-aa.html">aa</a></li><li class="progresssection"><a href="8-am.html">am</a></li><li class="progresssection"><a href="8-amd.html">amd</a></li><li class="progresssection"><a href="8-abp.html">abp</a></li><li class="progresssection"><a href="8-abc.html">abc</a></li><li class="progresssection"><a href="8-abif.html">abif</a></li><li class="progresssection"><a href="8-abic.html">abic</a></li><li class="progresssection"><a href="8-cu.html">cu</a></li><li class="progressnext"><a href="8-tur.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

